﻿using Md.Api.Entity.DapperModels.MdDB;
using Md.Api.Model.Manage.MdUserExperiencer.Request;
using Md.Dapper.Repositories.Md;

namespace Md.Api.Service.Manage.MdUserExperiencer;
/// <summary>
/// 通过编号更新体验师服务
/// </summary>
public class UpdateMdUserExperiencerByIdService : ApiBase<RequestUpdateMdUserExperiencerByIdModel>
{
    /// <summary>
    /// 体验师仓储
    /// </summary>
    public MdUserExperiencerRep mdUserExperiencerRep { get; set; }
    /// <summary>
    /// 执行
    /// </summary>
    protected override void ExecuteMethod()
    {
        var model = new MdUserExperiencerModel();

        model.UserExperiencerId = Parameter.UserExperiencerId;
        model.Name = Parameter.Name;
        model.Sex = Parameter.Sex;
        model.Birthday = Parameter.Birthday;
        model.Phone = Parameter.Phone;
        model.Email = Parameter.Email;
        model.State = Parameter.State;
        model.City = Parameter.City;
        model.Province = Parameter.Province;
        model.Region = Parameter.Region;
        model.Country = Parameter.Country;
        model.ZipCode = Parameter.ZipCode;
        model.Address = Parameter.Address;
        model.Scopes = Parameter.Scopes;
        model.Influence = Parameter.Influence;
        model.Works = Parameter.Works;
        model.UserId = Parameter.UserId;
        model.Display = Parameter.Display;
        model.Status = Parameter.Status;
        model.DelFlag = "0";
        model.Reason = Parameter.Reason;
        model.Remark = Parameter.Remark;
        model.UpdateBy = userKey?.ToString();
        model.UpdateTime = DateTime.Now;

        var res = mdUserExperiencerRep.UpdateMdUserExperiencerById(model);

        if (res > 0)
        {
            Result.Data = mdUserExperiencerRep.GetMdUserExperiencerById(model.UserExperiencerId);
        }
        else
        {
            Result.Data = res;
        }
    }
}

